<?php $this->headTitle("Gestion du magasin") ?>
<h4>Gestion du magasin</h4>

<h3>Images du magasin</h3>

<div class="control-group">
    <button class="add_store_picture btn btn-info" type="button"><i class="icon-plus icon-white"></i> Ajouter une image</button>
</div>

<?php if ($this->carouselItems): ?>
    <div id="grid-container">
        <table style="border: 1px solid" cellpadding="0" cellspacing="0" border="0" class="display" id="pictures-grid" width="100%">
            <thead>
            <tr>
                <th style="width: 30px;"></th>
                <th style="width: 150px;">Image</th>
                <th>Texte</th>
                <th>Début validité</th>
                <th>Fin validité</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($this->carouselItems as $index => $storePicture): ?>
                <?php if (file_exists(realpath(Application::getCarouselPicturesPath() . '/store/' . $storePicture['id'] . '.jpg'))) : ?>
                    <tr class="<?php echo ($index %2) ? 'even' : 'odd'?>">
                        <td>
                            <nobr>
                                <a href="/admin-store/edit/id/<?php echo $storePicture['id'] ?>">
                                    <img src="/images/icons/image_edit.png" title="Editer l'image"/>
                                </a>
                                <a href="/admin-store/delete/id/<?php echo $storePicture['id'] ?>" class="delete-link">
                                    <img src="/images/icons/image_delete.png" title="Supprimer l'image"/>
                                </a>
                            </nobr>
                        </td>
                        <td>
                            <img class="img-polaroid" src='/images/carousels/store/thumbs/<?php echo $storePicture['id'] ?>.jpg'/>
                        </td>
                        <td><?php echo $storePicture['item_text'] ?></td>
                        <td><?php echo date_format(date_create($storePicture['date_in']), 'd/m/Y') ?></td>
                        <td><?php echo date_format(date_create($storePicture['date_out']), 'd/m/Y') ?></td>
                    </tr>
                <?php endif ?>
            <?php endforeach ?>
            </tbody>
        </table>
    </div>

    <script>
        $(document).ready(function () {
            gridInFrench('#pictures-grid');
        });

        $('.delete-link').confirmModal({
            confirmTitle     : 'Confirmation de suppression',
            confirmMessage   : 'Etes vous sûr de vouloir supprimer cette image ?',
            confirmOk        : 'Oui',
            confirmCancel    : 'Non',
            confirmDirection : 'rtl'
        });
    </script>
<?php else: ?>
    <p>Il n'y a aucune image, veuillez en ajouter</p>
<?php endif ?>

<div class="control-group">
    <button class="add_store_picture btn btn-info" type="button"><i class="icon-plus icon-white"></i> Ajouter une image</button>
</div>

<script>
    $('.add_store_picture').click(function () {
        location.href = '/admin-store/add/';
    });
</script>